function veil() {
	$('#veil').show();
}
function unveil() {
	$('#veil').hide();
}
/**
 * Execute callback when app is ready.
 * @param fn
 */
function onAppReady(fn) {
	var n = 0;
	var COUNT_OF_ASYNC_PROC = 2;
	function aboutThisExample() {
		$('#aboutThisExample').html(msg_aboutThisExample);
		$('#descriptionOfThisExample h1').html(msg_aboutThisExample);
		$('#descriptionOfThisExample .content').html(msg_descriptionOfThisExample);
		$(window).resize(function() {
			var description = $('#descriptionOfThisExample');
			if (description.is(':visible')) {
				description.css({
					left: ($(document).width() - description.width()) / 2,
					top: ($(document).height() - description.height()) / 2
				});
			}
		});
		$('#aboutThisExample').click(function() {
			veil();
			var description = $('#descriptionOfThisExample');
			description.css({
				left: ($(document).width() - description.width()) / 2,
				top: ($(document).height() - description.height()) / 2
			}).show();
			$('#closeDescriptionButton').click(function() {
				description.hide();
				unveil();
			});
		});
		setTimeout(function() {
			$('#aboutThisExample').addClass('visible');
		}, 1500);
	}
	// execute callback function 
	var doWhenReady = function() {
		n++;
		if (n === COUNT_OF_ASYNC_PROC) {
			fn();
		}
	}

	var $ = jQuery;
	// Wait for DOM ready.
	$(document).ready(function() {
		doWhenReady();
	});
	// Wait for loading i18n messages.
	jQuery.i18n.properties({
		name : 'Messages',
		path : 'bundle/',
		mode : 'both',
		callback : function() {
			aboutThisExample();
			doWhenReady();
		}
	});

}

function modernizr(properties)
{
	var rtnArray = [];
	properties.forEach(function(property){
		if(!Modernizr[property]){
			rtnArray.push($.i18n.prop('msg_modernizr_' + property));
		}
	});
	if(rtnArray.length > 0){
		rtnArray.unshift($.i18n.prop('msg_modernizr_not_supported'));
	}
	return rtnArray;
}
